<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <input class="qs" type="checkbox">全选<br>
    <input class="a1" type="checkbox">1<br>
    <input class="a1" type="checkbox">2<br>
    <input class="a1" type="checkbox">3<br>
    <input class="a1" type="checkbox">4<br>
</body>
</html>
<script>
    var qs=document.querySelector(".qs")
    var aa=document.querySelectorAll('.a1')
    qs.onclick=function(){
        for(i=0;i<aa.length;i++){
            aa[i].checked=qs.checked
        }
    }
    for(i=0;i<aa.length;i++){
       aa[i].onclick=function(){
        var bb=document.querySelectorAll(".a1:checked")
        if(aa.length==bb.length){
            qs.checked=true
        }else{
            qs.checked=false
        }
       }   
    }
    var a= Math.random();
    console.log(a);
    console.log(parseInt(a*(1000000)))
</script>